<template>
	<div class="service-page full box relative flex-col p-safe">
		<scroll-view class="full" scroll-y>
			<div class="content-wrap">
				<u-parse :html="content" v-if="content" />
				<div v-else class="m-t-80">
					<u-empty text="未设置" mode="favor" />
				</div>
			</div>
		</scroll-view>
	</div>
</template>

<script>
	import { showLoading, request } from '@/utils/tool'
	export default {
		data() {
			return {
				type: "",
				content: "",
			}
		},
		onLoad(ev) {
			//类型: service=服务协议,privacy=隐私协议
			const { type } = ev
			this.type = type || "privacy"
			if (this.type === "service") uni.setNavigationBarTitle({ title: "服务协议" })
			this.initData()
		},
		methods: {
			async initData() {
				const hide = showLoading("正在获取")
				const { type } = this
				const resp = await request({
					url: "/index/policy",
					method: "GET",
					data: { type }
				}).finally(hide)
				const data = resp.data
				const { content } = data
				this.content = content || ""
				console.log(data, 'data');
			}
		}
	}
</script>

<style lang="scss" scoped>
	.service-page {
		.content-wrap {
			padding: 24rpx 32rpx;
			font-size: 32rpx;
			line-height: 1.6;
			color: rgba(0, 0, 0, 0.65);
		}
	}
</style>